home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / pcpil / pidoc2.txt < prev    next >
Text File  |  1994-03-01  |  40KB  |  1,042 lines

  1. DISK OR NETWORK FILES
  2.  
  3. To open a disk or network file the format of the FX: statement is as follows: 
  4.  
  5.        FX:pathname 
  6.  
  7. Where the word pathname represents the name of the disk file or network node 
  8. you wish to connect to. The pathname is formed per DOS file name conventions 
  9. for specifying drive, directory, root file name, and file suffix. If the file 
  10. exists, then it is made available for the PILOT program to read from or write 
  11. to. If the named file does not exist, then the FX: statement automatically 
  12. creates a file with that name, containing zero bytes of data. The file is 
  13. made available to read from or write to. The FIZ function may be used to 
  14. determine whether a file exists prior to attempting to open it.  
  15.  
  16. A disk file can be thought of as a list of bytes numbered from 0, for the 
  17. first byte, up to the size of the file. To read data from the file use the 
  18. FI: statement as shown above. The position-expression is evaluated to a 
  19. number.  The number represents an offset from the beginning of the file where 
  20. reading is to begin. The byte at the specified location in the file is the 
  21. first byte read into the string variable.  The number of bytes copied into 
  22. the string variable is equal to the maximum length established for the string 
  23. variable when it was created. If the FI: statement attempts to read beyond 
  24. the length of the disk file, then the string variable is padded out with 
  25. CHR(255) characters to its maximum length.  
  26.  
  27. EXAMPLE 1: Open a disk file named DATA, read 20 bytes from the file, starting 
  28. at byte position 15.  
  29.  
  30.        D: B$(20)
  31.        FX: DATA
  32.        FI:15,B$
  33.  
  34. The FO:, or FILE OUT statement can be used to write data into a disk file. 
  35. The position-expression determines the byte offset in the file where data is 
  36. first written. The number of bytes written to the file is equal to the length 
  37. of the data expression on the FO: statement.  
  38.  
  39. In using disk files you can think of the disk file as a long string of bytes. 
  40. Each byte is addressable by its byte offset from the file start. However, it 
  41. is often convenient to think of the file as a series of records, each record 
  42. being a pre-determined number of bytes in length. For example, assume that 
  43. your goal is to keep a file of student names and scores. You may decide that 
  44. the file will consist of a series of 50-byte records. Each one would hold the 
  45. name and score for one student. Also assume that in the first record of the 
  46. file is the number of the next available record in the file.  The following 
  47. program examples show how to set this file up initially and how to write a 
  48. record into the file. This example illustrates the use of the file 
  49. statements.  In practice, you would use KEEP to simplify the task.  
  50.  
  51. EXAMPLE 2: create file to save student scores
  52.  
  53.        FX:RECORDS        (create file named RECORDS)
  54.        FO:0,"  1"        (write 1 into the first record)
  55.  
  56. EXAMPLE 3: save a student name and score in the RECORDS file  
  57.  
  58.        R: set up strings 
  59.        D:NAME$(30),REC$(50),X$(3)
  60.       . . .  program runs here, assume that student
  61.       . . .  name is stored in NAME$, and score is
  62.       . . .  in the numeric variable SCORE
  63.        R: construct student record with trailing
  64.        R: CR and LF characters 
  65.        C:REC$(49,2) = CHR(13) !! CHR(10)
  66.        C:REC(1,30) = NAME$
  67.        C:REC(31,18) = SCORE
  68.        R:determine next available record
  69.        FX:RECORDS
  70.        FI:0,X$   
  71.        FO:X$,REC$
  72.        R:update record number at the start of file
  73.        C: X$(1,3) = X$ + 1
  74.        FO:0,X$
  75.        FX:
  76.  
  77. PRINTER OR AUXILIARY PORT FILES 
  78.  
  79. The system printer device, or the auxiliary RS-232 serial interface can be 
  80. accessed as a PILOT file.  These special files can be used for output only. 
  81. To open the printer as a file use: 
  82.  
  83.        FX:PRN:
  84.  
  85. To open the serial interface as a file use: 
  86.  
  87.        FX:AUX:
  88.  
  89. The serial interface can be used as a simple control mechanism for video disc 
  90. or other external devices which have an RS-232 interface.  One consideration 
  91. for such devices is that both the computer and the other device must be set 
  92. up to communicate at the same baud rate (speed).  The baud rate on the 
  93. computer end is set up prior to starting your PILOT program by issuing the 
  94. DOS MODE command. This command could be placed in your AUTOEXEC.BAT file so 
  95. that it happens each time the computer is turned on. A sample MODE command to 
  96. set the baud rate to 1200 baud might look like this: 
  97.  
  98.        MODE COM1:1200,N,8,1
  99.  
  100. See the DOS manual for further information on the MODE command.  
  101.  
  102. Once open, the FO: statement may be used to write data to the printer or to 
  103. the device attached to the serial interface. The format of the FO: statement 
  104. is: 
  105.  
  106.        FO:0,expression
  107.  
  108. The "0" is ignored for these devices. The string value of the expression is 
  109. written to the device. No extra control characters are automatically written 
  110. after the expression value. If you wish to transmit a RETURN or LINE FEED 
  111. after the data, you must append these characters to the data.  
  112.  
  113. EXAMPLE 4: Write a line to the printer, then space the printer up one line.  
  114.  
  115.        FX:PRN:
  116.        FO:0,"Hello world." !! CHR(13) !! CHR(10)
  117.  
  118.  
  119. EXAMPLE 5: Control Video Disc Player From PILOT.  This example assumes that a 
  120. Pioneer LDV-700 and Pioneer IU-04 interface is attached to the serial 
  121. interface and that the baud rate has been set via a MODE command prior to 
  122. running the PILOT program.  
  123.  
  124.        FX:AUX:
  125.        R: next play frame 1000 as still frame
  126.        FO:0,"F1000SI" !! CHR(13)
  127.        R: next line plays 5 sec from frame 2345
  128.        FO:0,"F2345SP@5" !! CHR(13)
  129.        R: next line turns off video disc
  130.        FO:0,"Q" !! CHR(13)
  131.  
  132. The actual command strings written to the video disc player by the above FO: 
  133. statements may change for another brand or model of disc player. But the 
  134. method used in PILOT to control the device is the same for any device which 
  135. has a serial, RS-232 interface.     
  136.  
  137. HEAP FILE
  138.  
  139. The heap facility permits the PILOT program to make use of very large 
  140. computer memory as a temporary, very fast file. The program creates a heap 
  141. out of otherwise unused RAM. Once the heap is created the program can write 
  142. string data to the heap, and read it back later in the program.  In effect 
  143. the heap becomes an unlimited extension to the program string space.  When 
  144. the program ends and returns to DOS the contents of the heap are discarded.  
  145.  
  146. To establish the heap execute the following statement once at the beginning 
  147. of the program use:  
  148.  
  149.        FXH: n
  150.  
  151. where n is a number indicating the size, in bytes, to be set aside for the 
  152. heap. An XSPACE error occurs if the amount is to great for the system in use.  
  153.  
  154. To estimate the maximum size of the heap for a particular system proceed as 
  155. follows. From DOS before running PILOT run CHKDSK to get the amount of unused 
  156. memory. From that subtract 182K for PILOT. The remainder is available. If the 
  157. program is to call other programs or languages (via EXEC) you must leave 
  158. sufficient unused space for those programs.  
  159.  
  160. Only the first successful FXH: statement has an effect. Once the heap is set 
  161. up, other FXH: statements are ignored.  
  162.  
  163. The heap does not count as the one allowed open file. So even though the heap 
  164. is in use one additional disk file may be open.  
  165.  
  166. To write data to the heap use the following: 
  167.  
  168.        FOH: n,string-value
  169.  
  170. where n is the byte position within the heap at which the string-value is to 
  171. be written. The first byte position in the heap is location 0.  The string 
  172. value may be a string variable name or any string expression.  
  173.  
  174. To retrieve the data into a string variable again use the statement: 
  175.  
  176.        FIH: n,V$
  177.  
  178. where n is the position in the heap from which the data is to be read, and V$ 
  179. is any string variable name.  
  180.  
  181. The statements FOH: and FIH: work exactly like FO: and FI: for disk files. 
  182. The difference is that writing and reading the heap is very fast, taking no 
  183. more time than a simple assignment statement. The heap can serve as a quick 
  184. access storage bin for sprite tables, graphic images, machine language 
  185. subroutines, etc.  
  186.  
  187. Items to be loaded from disk files into the heap must be moved there through 
  188. string variables by reading from disk to the string via FI:, then writing to 
  189. the heap from the string via FOH:.  
  190.  
  191. EXAMPLE 6: Create a heap and move two  graphic images to the heap.  
  192.  
  193.        FXH: 30000
  194.        DX:P$(10000)
  195.        FX:PIC1.SQZ
  196.        FI:0,P$
  197.        FOH:0,P$
  198.        FX:PIC2.SQZ
  199.        FI:0,P$
  200.        FOH:10000,P$
  201.  
  202. EXAMPLE 7: display a graphic image from the heap 
  203.  
  204.        FIH:10000,P$
  205.        V:P$
  206.  
  207. See also:  AUX(0) function,  FIZ function,  MODE (DOS manual) 
  208.  
  209. GRAPHICS - display graphic images 
  210.  
  211.        G: turtle-graphics-command-list
  212.        GX: graphics-image-filename
  213.        GSX: graphics-image-filename
  214.  
  215. The GRAPHICS statement is used to control the graphics screen display. There 
  216. are several types of graphics which can be used: 
  217.  
  218. TURTLE GRAPHICS: to draw colored points, lines, and shapes either by absolute 
  219. pixel coordinates or by directing an invisible "turtle" to walk in various 
  220. directions while drawing a line wherever it has gone.  Turtle graphics in 
  221. PILOT is similar to what is found in the LOGO language.  
  222.  
  223. IMAGE GRAPHICS: a graphics image is a stored picture or full screen graphic 
  224. that has been created outside of the PILOT program and stored in a disk file. 
  225. The GX: statement can display such a picture by painting the entire image on 
  226. the screen in one operation.  
  227.  
  228. SCREEN SAVE/RESTORE: To facilitate the creation of dialog boxes, pull-down 
  229. menus, and other types of screen overlays, the GSX: and GX: statement provide 
  230. a way to take a snapshot of the screen, save it in internal memory, then 
  231. instantly put the screen back as it was on command.  
  232.  
  233. SPRITE GRAPHICS: a sprite is a smaller picture which can be placed anywhere 
  234. on the screen or can be moved around (animated) on the screen by attaching it 
  235. to the turtle, and allowing the turtle to "drag" it around on the screen.  
  236.  
  237. TURTLE GRAPHICS
  238.  
  239. The turtle graphics commands are valid only for graphic screen modes, namely 
  240. modes 4, 5, 6, 13, 14 and 16.  
  241.  
  242. The G: statement is used for turtle graphics.  After the colon you can write 
  243. a list of turtle graphics commands. The list can contain one or more of the 
  244. following commands, separated by ";" characters.  To draw lines you tell the 
  245. (invisible) turtle which direction to head and how far to walk.  As the 
  246. turtle walks it can leave a colored line on the screen.  The turtle's heading 
  247. ranges from 0 degrees (straight up) to 359 degrees with the heading angle 
  248. increasing as it rotates to the right.  If the turtle walks off the screen it 
  249. comes back on the opposite edge.  In the command descriptions below n 
  250. represents a numeric variable, an integer constant, or an expression enclosed 
  251. in parentheses.  
  252.  
  253. Ar,d - arc or circle
  254.  
  255. Draw an arc with radius of r turtle steps, starting at the angle equal to the 
  256. turtle heading, and sweeping through an angle of d degrees. The turtle 
  257. heading rotates right by d degrees, the turtle location remains unchanged. If 
  258. d=360 a circle is drawn 
  259.  
  260. Bx,y - solid color bar
  261.  
  262. Draws a bar, or solid box, with the upper left corner at the turtle location, 
  263. x and y are the number of pixels across and down of the bar.  The turtle is 
  264. moved to one pixel down and to the right of the bar.  
  265.  
  266. Pn - paint an area
  267.  
  268. Paints an area to color number n. The painted area starts at the turtle 
  269. location and includes all adjacent pixels with the same color as the starting 
  270. pixel. It is a flood fill which recursively wraps around all corners and 
  271. shapes as necessary.  
  272.  
  273. Hn - set turtle heading to n degrees 
  274.  
  275. Rn - rotate turtle heading right n degrees 
  276.  
  277. Ln - rotate turtle heading left n degrees
  278.  
  279. Fn - walk forward n steps
  280.  
  281. Gx,y - set turtle location to pixel x,y
  282.  
  283. Dx,y - draw a line to pixel location x,y
  284.  
  285. Cn - set line color for F or D to n (0-3)
  286.  
  287. Cn,w - set line color and line width  
  288.  
  289. The width can be set to 0 (no line), 1, 2 or 3.  The default is a 1 pixel  
  290. wide line.  The  line width affects  draw, forward, and arc commands.  
  291.  
  292. E - erase screen to background color
  293.  
  294. *n(...) - repeat the enclosed commands n times
  295.  
  296. Wn - wait, or delay n 60ths of a second
  297.  
  298. Xn - set horizontal scale factor 
  299.  
  300. Yn - set vertical scale factor
  301.  
  302. S var$ - make string variable var$ the current sprite table 
  303.  
  304. Sn - sprite select
  305.  
  306. Display, or erase sprite n, and attach sprite n to the turtle. 
  307.  
  308. S0 - detach sprite from the turtle
  309.  
  310. Jn - jump back to a previous sprite
  311.  
  312. Move turtle to location of sprite n and attach sprite n to the turtle. 
  313.  
  314. MODES AND COLORS
  315.  
  316. Turtle graphics can be performed in modes 4,5,6,13,14 and 16. In modes 4 and 
  317. 5 the screen is 320 pixels  across by 200 down with valid line colors 0-3.  
  318. Color 0 selects the current background color as set by TYPE SCREEN.  Colors 
  319. 1, 2 and 3 are determined by the current mode. See the TYPE SCREEN statement 
  320. for more information on modes and colors.  
  321.  
  322. MODES 4 and 5: 320 x-pixels, 200 y-pixels, colors 0-3
  323. MODE 4 COLORS: 1-green, 2-red, 3-yellow
  324. MODE 5 COLORS: 1-cyan, 2-magenta, 3-white
  325.  
  326. Background color for modes 4 and 5 is color number 0. It can be selected from 
  327. colors 0-15, with two possible intensities as documented under TYPE SCREEN.  
  328.  
  329. In mode 6 the screen is 640 pixels across by 200 down with one valid line 
  330. color as set by the TS:Xn command.  
  331.  
  332. MODE 6: 640 x-pixels, 200 y-pixels, colors 0-1 
  333.  
  334. With an EGA (Extended Graphics Adapter) the additional graphics modes are: 
  335.  
  336. MODE 13: 320 x-pixels, 200 y-pixels, colors 0-15
  337.  
  338. MODE 14: 640 x-pixels, 200 y-pixels, colors 0-15
  339.  
  340. MODE 16: 640 x-pixels, 350 y-pixels, colors 0-15
  341.  
  342. SCALE FACTORS
  343.  
  344. The X and Y scale factors can be adjusted for a particular display to achieve 
  345. uniformity in horizontal and vertical step sizes.  The default value is X1;Y1 
  346. , which makes a turtle step size equal to one quarter of a pixel.  To make a 
  347. step equal to a pixel set the values to X4;Y4.  
  348.  
  349. Scale factors can also be used to change the aspect ratio between x and y 
  350. directions as shown in the ellipse example below. 
  351.  
  352. EXAMPLE 1: Turtle graphics examples.
  353.  
  354. G: *18(F60;R20)        draws a circle
  355.  
  356. G: *4(F80;L90)         draws a box
  357.  
  358. G: C2;*5(F160;R144)    draws a red star
  359.  
  360. G: X6;Y3;*36(F10;R10)  draws an ellipse
  361.  
  362. G: G10,20;D15,85       line (10,20)-(15,85)
  363.  
  364. G: G(X+30),40;F(60*D)  expressions as arguments
  365.  
  366. G: A50,360;P2          a circle, filled in
  367.  
  368. G: B20,20;B40,40       two bars
  369.  
  370. G: C1,3;A50,180        a wide-line semi-circle
  371.  
  372.  
  373.  
  374. IMAGE GRAPHICS
  375.  
  376. A graphics image can be created by the GIE program or by other graphics 
  377. creation products which can produce a 16K bit-mapped screen image, often 
  378. called BSAVE/BLOAD format. Many useful graphics creation products do not use 
  379. the BSAVE/BLOAD format to store pictures on disk.  However, in these cases 
  380. there is often a conversion process that can be used to convert the picture 
  381. files to BSAVE/BLOAD format. The BSAVER utility may be useful doing this type 
  382. of conversion. See also: Appendix C. 
  383.  
  384. To load a graphics image from a disk file and display it on the screen, first 
  385. insure that the screen is in a graphics mode (4,5 or 6) and set the desired 
  386. background color (if not already set). The following statement shows how to 
  387. do these two things:  
  388.  
  389.        TS:M4;B2
  390.  
  391. Then execute the following command:
  392.  
  393.        GX:filename
  394.  
  395. PILOT can also save the current screen  display in a disk file by the 
  396. following command:  
  397.  
  398.        GSX:filename
  399.  
  400. The GX: and GSX: statements may also be used in text modes (0 though 3). The 
  401. screen image file produced is 2K for 40 column screens or 4K for 80 column 
  402. screens.  Prior to executing a GX: statement to display a text screen, the 
  403. screen mode must be set to the same mode in which the screen image was saved 
  404. via a previous GSX: statement.  
  405.  
  406. The PIQ utility program may also be of interest when using image graphics. It 
  407. can be used to compress a graphics image from BSAVE/BLOAD format into a 
  408. compact format which takes up less disk space and displays more quickly. PIQ 
  409. also provides for various screen wipes and special effects for partial or 
  410. complete screen images. See also: Appendix C.  
  411.  
  412. SCREEN SAVE/RESTORE
  413.  
  414. The GSX: statement can be used to make a copy of the current screen in ram 
  415. memory. The command format is: 
  416.  
  417.        GSX:           (no arguments follow the colon)   
  418.  
  419. This command happens instantaneously, so it is useful for saving the screen 
  420. display when the program is to be interrupted for a menu, dialog box, or 
  421. other student-invoked control function.  
  422.  
  423. Once the screen has been saved, the program can modify the screen as 
  424. necessary to converse with the student. This might involve the display of a 
  425. menu box, help screen, note pad, calculator, or glossary.  When the auxiliary 
  426. function is complete, the screen can be restored to its original state by the 
  427. command: 
  428.  
  429.        GX:           (no arguments follow the colon)
  430.  
  431. The screen restore is instantaneous. Not only is the visual data put back as 
  432. it was, but the cursor location, colors, and current and previous viewport 
  433. data is put back as well. It is, however, up to the program to insure that 
  434. prior to execution of the GX: statement, the screen mode is set to the screen 
  435. mode that existed at the time of the GSX: statement. If the mode has not 
  436. changed in the interim, then it need not be changed back again. But if the 
  437. screen mode did change after the GSX: statement, then it must be changed back 
  438. by the TS:Mn command just prior to the GX: statement. The MOD built-in 
  439. function may be useful in determining the screen mode prior to the GSX: 
  440. statement if it is not already known.  
  441.  
  442. Unlike other uses of the Graphics statement, the uses of GSX: and GX: are 
  443. valid in any screen mode from 0 to 6.  
  444.  
  445. EXAMPLE 2: SYSX routine using GSX: and GX:
  446.  
  447.        R: come here when user pushes ESC key
  448.        *SYSX 
  449.        GSX:
  450.        TS:V10,30,5,11
  451.        TX:*******************
  452.          :
  453.          :  M  -  Main menu
  454.          :  C  -  Calc    
  455.          :  G  -  Glossary
  456.          :              
  457.          :*******************
  458.        AS:
  459.        M:M!m
  460.        JY:MENU
  461.        M:C!c
  462.        JY:CALC
  463.        M:G!g
  464.        JY:GLOSS
  465.        *SYSX2
  466.        GX:
  467.        E:
  468.  
  469.        *CALC 
  470.        TX:Input expression
  471.        :such as  123.5 * 7
  472.        :or ENTER to return
  473.        A:
  474.        J(%B=" "):SYSX2
  475.        X:"C:Z=" !! %B
  476.        T:#Z
  477.        W:30
  478.        J:CALC
  479.  
  480.        *GLOSS
  481.        TX:Glossary...
  482.       ...
  483.        W:100   
  484.        J:SYSX2
  485.  
  486. SPRITE GRAPHICS
  487.  
  488. A sprite is a picture, similar to a graphics image, except that a sprite is 
  489. smaller. A graphics image is 320 pixels across by 200 pixels up and down (the 
  490. entire screen). A sprite can range from 32 pixels by 32 pixels, to 64 pixels 
  491. by 128 pixels. Sprites can be displayed in graphics modes 4, 5 and 6 only.  
  492.  
  493. A sprite can be used as a way to draw diagrams or pictures on the screen. One 
  494. of the unique features of a sprite is that it can be animated or moved on the 
  495. screen. This is accomplished by use of the turtle graphics commands of the G: 
  496. statement. To move a sprite you need only "attach" the sprite to the turtle, 
  497. then move the turtle via forward or draw commands. As the turtle moves, 
  498. rather than drawing a line as it usually would, it moves the sprite along 
  499. with it on the screen. To take it a step further, you can move several 
  500. sprites apparently at the same time by telling the turtle to take turns 
  501. jumping from one sprite to the next, moving each a little bit on each turn.  
  502.  
  503. The use of sprites is discussed in great detail in the section of this 
  504. document entitled "Sprites".  
  505.  
  506. JUMP - goto a destination
  507.  
  508.        J: label
  509.        J: #variable
  510.        J: @A
  511.        J: @P
  512.        J: @-P
  513.        J: @M
  514.  
  515. Unless otherwise instructed, PILOT executes each statement in your program 
  516. one after the other, in the exact order that the statements are written. With 
  517. the JUMP statement you can alter this order by branching to a specified 
  518. location. The location can be a statement label, a numeric variable, or one 
  519. of four possible special destinations which are commonly needed.  
  520.  
  521. JUMP TO A LABEL
  522.  
  523. The first form of the JUMP statement above transfers control to the statement 
  524. following the specified label. Although the statement label in the program is 
  525. preceded by an "*", you do not put the "*" character on the JUMP statement.  
  526.  
  527. EXAMPLE 1: jump to a label
  528.  
  529.        J:PART4
  530.        . . .
  531.       *PART4 T:This is chapter 4.
  532.  
  533. If the label name to which the program should jump is contained in a string 
  534. variable, use the Execute Indirect statement to perform the jump as shown in 
  535. this example.  
  536.  
  537. EXAMPLE 2: jump to a string variable, say X$:
  538.  
  539.        X:"J:" !! X$
  540.  
  541. or if the jump is to be conditional:
  542.  
  543.        X(condition):"J:" !! X$
  544.  
  545. JUMP TO A NUMERIC VARIABLE
  546.  
  547. The second format shown above permits a jump to a location stored in a 
  548. numeric variable. This is a special purpose use which can be used in only one 
  549. way. The numeric variable used in the Jump can be set by the statement: 
  550.  
  551.        C: X = %E
  552.  
  553. which sets variable X to the jump location of the return point from the most 
  554. recent Use statement. Then to jump to this location use: 
  555.  
  556.        J: #X
  557.  
  558. This special case Jump is used only in the construction of an Escape routine 
  559. which links to another module then expects to return to the point from which 
  560. the escape routine was called.  
  561.  
  562.  
  563. JUMP TO LAST ACCEPT STATEMENT
  564.  
  565. The third form of the JUMP shown above is used to branch back to the last 
  566. ACCEPT statement that was executed. This is useful to allow the student to 
  567. re-answer the question just answered.  
  568.  
  569. EXAMPLE 3: jump to last ACCEPT
  570.  
  571.        T:What is 2+3?
  572.        A:
  573.        M:5
  574.        TY:Right
  575.        TN:No, try again
  576.        JN:@A
  577.  
  578.  
  579. JUMP TO THE NEXT MATCH
  580.  
  581. When a student response is evaluated, there is sometimes a series of MATCH 
  582. commands to test for various correct and incorrect possibilities.  After each 
  583. MATCH might be a series of statements to be executed if the MATCH is YES. 
  584. Otherwise it is convenient to jump directly to the next MATCH to check for 
  585. the next possibility.  
  586.  
  587. EXAMPLE 4: jump to next MATCH
  588.  
  589.        M:calcium
  590.        JN:@M
  591.        . . . 
  592.        M:silicon
  593.        JN:@M
  594.        . . . 
  595.        M: . . .
  596.  
  597.  
  598. JUMP TO NEXT PROBLEM
  599.  
  600. If a program consists of a set of questions or problems, presented one after 
  601. the other, it can be convenient to start each question section with the P: 
  602. statement. Then, from anywhere within the previous question, the program can 
  603. branch to the next problem without having to place a label on each question.  
  604.  
  605. EXAMPLE 5: jump to next problem
  606.  
  607.        M:Italy
  608.        TY:Right, let's go on.
  609.        JY:@P
  610.        . . .
  611.        P:
  612.        T:Question 14.
  613.        T:...
  614.    
  615.  
  616. JUMP TO LAST PROBLEM
  617.  
  618. The final format of the Jump permits the program to jump back to the last 
  619. Problem statement passed. This could be useful in going back to the start of 
  620. the current section or when going back to accept another answer when the 
  621. cursor must be positioned prior to letting the student answer again.  
  622.  
  623. EXAMPLE 6: jump to last Problem
  624.  
  625.        P:
  626.        TS:G10,5;F4;B1
  627.        A:
  628.        . . .
  629.        J:@-P
  630.  
  631. See also:  STATEMENT LABELS
  632.  
  633.  
  634. KEEP RECORDS - save data on disk
  635.  
  636.        K: expression
  637.  
  638. The KEEP statement  provides a simple way to write data to a disk file for 
  639. later manipulation. It can be used to store student progress records, scores, 
  640. remarks from the student to the author, student answers, etc. The file 
  641. written by the KEEP statement is a text file which can be displayed by the 
  642. DOS TYPE command or examined by a text editor, such as EZ. It can also be 
  643. read by another program to perform statistics or other reporting.  
  644.  
  645. The default file name used to store data written by the KEEP statement is 
  646. K.REC, but the K option of the PROBLEM statement can be used to specify any 
  647. filename, pathname, or network file name to be used instead. You need not 
  648. take any action to create the keep file prior to running the PILOT program. 
  649. If it does not exist, the KEEP statement automatically creates the file.  
  650.  
  651. Each time the KEEP statement is executed, the string value of the expression 
  652. after the colon is written to the current keep file.  A new-line sequence is 
  653. appended to the string expression as it is written to the file. This means 
  654. that each KEEP adds one text line to the keep file.  
  655.  
  656. The keep file continues to grow until it is explicitly erased by a DOS 
  657. command.  
  658.  
  659. EXAMPLE 1: save student name and score
  660.  
  661.        T:Well, $NAME$ , you got #SCORE right.
  662.        K: NAME$ !! SCORE
  663.        E:
  664.  
  665.  
  666. See also: PROBLEM
  667.  
  668. LINK - chain to another program file
  669.  
  670.  
  671.        L: filename
  672.        L: filename, destination
  673.  
  674. Most programs you write should be divided into separate files, or modules. 
  675. This facilitates program editing and helps keep an organized structure to 
  676. your program. The LINK statement is used to transfer control from one program 
  677. module to another.  LINK is similar in use to the CHAIN statement of BASIC. 
  678. When LINK is executed, the current program is removed from memory and the 
  679. linked program is loaded into memory.  All variables are retained from one 
  680. module to the next. If you wish to Link to a string variable, see example 3 
  681. below.  
  682.  
  683. EXAMPLE 1: link to another program file
  684.  
  685.        L:CHAPTER7
  686.  
  687. In the above, the program is assumed to be in file CHAPTER7.PIL.  
  688.  
  689. With LINK you can start the new module at the beginning or at any label 
  690. within the module.  
  691.  
  692. EXAMPLE 2: link to a label in another file
  693.  
  694.        L:CHEMX,Q3
  695.  
  696. The above links to file CHEMX.PIL, then does an automatic JUMP to label Q3 in 
  697. that file.  
  698.  
  699. EXAMPLE 3: link to file name in a string variable, say X$ 
  700.  
  701.        X:"L:" !! X$
  702.  
  703. See also: JUMP
  704.  
  705. MATCH - compare student response
  706.  
  707.        M:pattern
  708.        MS:pattern
  709.        MJ:pattern
  710.        MX:expression
  711.  
  712. MATCH is used to test the answer given by the student to a previous ACCEPT 
  713. statement. There are two types of MATCH, pattern matching and numerical 
  714. matching. In either case, the result of the MATCH is a YES or a NO. The YES 
  715. or NO can subsequently be tested by use of the Y or N conditionals.  
  716.  
  717. PILOT does not make any assumptions about the correctness or incorrectness of 
  718. an answer. You can use MATCH equally well to test for correct answers or 
  719. anticipated incorrect answers. YES does not necessarily always mean correct 
  720. and NO does not necessarily always mean incorrect.  
  721.  
  722. PATTERN MATCHING
  723.  
  724. MATCH compares the student answer buffer (%B) with the pattern after the 
  725. colon on the MATCH statement.  The result is a YES or NO match which can be 
  726. tested by the Y or N conditionals.  When comparing, if the student answer 
  727. contains the match pattern anywhere within the student answer, it is 
  728. considered a YES match.  
  729.  
  730. EXAMPLE 1: simple MATCH
  731.  
  732.        M:HAT
  733.                 student answer: CHATTER gives YES
  734.                 student answer: HAT gives YES
  735.                 student answer: CAT gives NO
  736.  
  737. SPECIAL MATCH CHARACTERS
  738.  
  739. When writing the pattern, you can use the following special characters within 
  740. the pattern.  
  741.  
  742. *    matches any one character
  743.  
  744. &    matches any string of zero or more characters  
  745.  
  746. It can be considered to separate several items which must occur in specific 
  747. order but that may have other data between items.  
  748.  
  749. @    separate items which must be present but may be in 
  750.          any order  
  751.  
  752. !      separate alternative patterns
  753.  
  754. %    matches only a space or the start or end of the answer 
  755.  
  756.  
  757. NEGATION
  758.  
  759. If the first character of the match pattern is the not character, "^" , then 
  760. the sense of the match is inverted. That is, it will yield a YES if the match 
  761. pattern is NOT found in the student answer, and will yield a NO if the match 
  762. pattern IS found in the student answer.  
  763.  
  764.  
  765. SPELLING ERRORS
  766.  
  767. The S modifier can be appended to the MATCH op code.  MS: is sometimes called 
  768. MATCH SPELLING.  The Spelling modifier makes the MATCH more liberal in its 
  769. comparison. If the student answer is off by only a minor spelling error, then 
  770. the MATCH is still YES. A minor spelling error is one wrong letter or two 
  771. inverted letters.  
  772.  
  773. EXAMPLE 2: Various MATCH statements.
  774.                 
  775. M:HAT
  776.                           HAT - YES
  777.                           CHATTER - YES
  778.  
  779. M:%HAT%
  780.                           HAT - YES
  781.                           CHATTER - NO
  782.  
  783. M:CAT&DOG
  784.                           CATDOG - YES
  785.                           CATS AND DOGS - YES
  786.                           DOGS AND CATS - NO
  787.  
  788. M:CAT@DOG
  789.                           CATDOG - YES
  790.                           CATS AND DOGS - YES
  791.                           DOGS AND CATS - YES
  792.  
  793. MS:GREEN
  794.                           GREAN - YES
  795.                           GRENE - YES    
  796.  
  797. MS:CAT!DOG
  798.                           CAT - YES
  799.                           COT - YES
  800.                           DIG - YES
  801.  
  802. M:H*T
  803.                           HOT - YES
  804.                           HAT - YES
  805.                           HT - NO
  806.  
  807. M:^DOG
  808.                           DOG - NO
  809.                           CAT - YES
  810.  
  811. M:RED&BLUE!HOT
  812.                           RED, WHITE, BLUE - YES
  813.                           HOT - YES
  814.                           RED - NO
  815.  
  816. SYSTEM VARIABLES AFTER A MATCH
  817.  
  818. There are three system variables set after a pattern match. Each is set to 
  819. zero if the pattern did not match, otherwise each is set as follows:  
  820.  
  821. %N  -  alternate answer indicator
  822.  
  823. %N is the number of the alternate answer which matched when an "!" is used to 
  824. separate possible alternate answers.  For example, M:CAT!DOG!HORSE if the 
  825. student types CAT, %N=1, if the student types DOG, %N=2, etc.  
  826.  
  827. %M  -  offset of match in student answer
  828.  
  829. %M is the byte location within the student answer (ie.  subscript within %B) 
  830. at which the match began.  
  831.  
  832. %L  -  match length
  833.  
  834. %L is the number of bytes within the student answer (%B) which matched.  
  835.  
  836. Example: 
  837.  
  838.        M:C&T
  839.  
  840. If student reply is SCANTY, 
  841.  
  842.        %M=2, %L=4 
  843.  
  844. AUTOMATIC JUMP TO NEXT MATCH 
  845.  
  846. Appending the J modifier to the MATCH op code causes a JUMP to the next MATCH 
  847. if this match results in a NO.  
  848.  
  849. NUMERIC MATCH
  850.  
  851. The MX: statement is used to make numeric comparisons. The argument after the 
  852. colon is an expression. The expression is evaluated, if the numeric value of 
  853. the expression is true (non-zero), the result of the MATCH is YES. If the 
  854. numeric value of the expression is false (0), then the result of the MATCH is 
  855. NO.  
  856.  
  857. EXAMPLE 3: numeric matching
  858.  
  859.         MX: FLO(%B) > 50
  860.         TY:Too big, try again.
  861.  
  862.         MX: X > 98.3  &  X < 98.9
  863.         TY:Close enough.
  864.  
  865. See also:  ACCEPT, JUMP, CONDITIONALS
  866.  
  867. NEW CHARACTER - define char pattern
  868.  
  869.        N:c . . . / / /       (64 . and / characters)
  870.  
  871. PILOT uses Ascii character codes 32 through 256 for printable characters. The 
  872. ASCII code table defines only the characters from 32 through 127.  This 
  873. leaves 128 characters, from 128 to 256, for other uses. These characters are 
  874. used in the text modes (modes 0 through 3) for the extended text mode 
  875. characters. These include various line drawing characters, mathematical 
  876. symbols and foreign characters. In the graphics modes (modes 4 through 6) the 
  877. 128 extra characters are set aside as user-definable special characters. This 
  878. means that you can design your own characters for special type fonts, foreign 
  879. languages, or other special symbols.  
  880.  
  881. The special characters should not be confused with character "fonts". Special 
  882. characters defined by the N: statement are restricted to the standard 8 by 8 
  883. pixel character size. Character fonts, described under the NS: statement, can 
  884. be used for smaller or larger character representations.  
  885.  
  886. The NEW CHARACTER command can be used to change the 8 by 8 dot pattern for 
  887. any of the 128 changeable characters. Prior to execution of any N: statement 
  888. the characters from 128 to 255 have unpredictable display patterns in the 
  889. graphics modes.  Once at least one N: statement has been executed, the 
  890. characters from 128 to 255 that have not been explicitly changed will have 
  891. the same display pattern as the corresponding character in the range 0 to 
  892. 127.  The N: statement has no effect on the characters displayed in text 
  893. modes. In text modes, the characters displayed are always the default text 
  894. mode extended character set, as shown in Appendix B.  
  895.  
  896. The letter c shown in the format of N: above stands for any character from 
  897. 128 to 255. (The EZ editor provides a way to enter characters in that range 
  898. into a program.)  It is followed by 64 periods and slash characters.  They 
  899. depict the pattern of zero (.) and one (/) bits that will be used to display 
  900. the character.  The 64 bits may be given on 8 lines of 8 bits each, to give a 
  901. visual picture of the character pattern.  The 64 bits may also be given all 
  902. on one line or any desired format that adds up to 64.  Intervening spaces and 
  903. new lines are ignored.  
  904.  
  905.  
  906. CHARACTER EDITOR
  907.  
  908. Although you could write an N: statement and manually determine the pattern 
  909. of dots and slashes, you would normally use the Character Editor included in 
  910. the EZ editor. It makes the process of creating character patterns very easy. 
  911. EZ also allows you to see your re-defined characters while you are editing 
  912. your program if you wish.  
  913.  
  914. See also: The EZ Editor 
  915.  
  916. NEW HEIGHT/WIDTH - set font size
  917.  
  918.  
  919.        NH: h,w
  920.  
  921. The NH: statement may be used to change the default font character cell size. 
  922. The font character cell size is used to compute row/column coordinates for 
  923. cursor addressing by the "TS:Gc,r" command when in font display mode.  
  924.  
  925. When a font is activated as the current font (see NS: statement) it has a 
  926. default character cell height and width, in pixels. This default height and 
  927. width are usually set to accommodate the largest character in the font. When 
  928. the program executes a TYPE SCREEN with a GOTO command to set the cursor, the 
  929. character cell height and width are used to compute the pixel location for 
  930. the cursor.  
  931.  
  932. A typical use of NH: is to set both height and width to 1. Thus the command 
  933. to set the cursor location has the effect of absolute pixel addressing. Thus 
  934. a font character could be written at any pixel on the screen.  
  935.  
  936. EXAMPLE 1: change to pixel addressing
  937.  
  938.        NH: 1,1
  939.  
  940. See also: NEW FONT
  941.  
  942. NEW FONT - set font mode
  943.  
  944.  
  945.        NS: variable$
  946.        NS: variable$,c1,c2,c3
  947.        NS:
  948.  
  949. The NS: statement may be used to set "font display mode". NS: may be executed 
  950. only with the screen in display mode 4 or higher. The "variable$" must be a 
  951. character string variable which contains the desired character font. In font 
  952. display mode all characters typed by the program or entered on the keyboard 
  953. are displayed in the type size and style of the active character font.  
  954.  
  955. Character fonts can be used to display text in characters that range in size 
  956. up to 24 by 24 pixels, and accommodate an unlimited variety of type styles.  
  957.  
  958. The character font may be one supplied with PILOT or may be one created by 
  959. using the Font Editor, described in a later section of this document.  
  960.  
  961. The NS: statement with no parameters after the colon may be used to turn off 
  962. font display mode and return to normal text display mode. Font display mode 
  963. is also turned off by the mode set command of the TYPE SCREEN statement.  
  964.  
  965. When font display mode is entered the font text cursor is placed in the home 
  966. position and color and spacing options are set to the defaults contained in 
  967. the font.  
  968.  
  969.  
  970. FONT COLORS 
  971.  
  972. A character font can define each character in one, two or three colors. So an 
  973. individual character can contain as many as three different colored pixels.  
  974. This provides for great flexibility in font design for outlines, drop 
  975. shadows, etc.  The three colors are numbered 1,2 and 3. Some fonts are 
  976. designed with one color only. In this case the one color is normally color 3.  
  977.  
  978. The NS: statement provides for a way to re-map the three colors to any other 
  979. three colors. In modes 4 and 5 the three new colors can be from 0 to 3. But 
  980. in EGA extended modes (13,14 and 16) the three new colors can be selected 
  981. from 0 through 15. So at any one time a character can be displayed in up to 
  982. three of the colors supported in the current screen mode.  
  983.  
  984. To re-map the colors use the second form of the NS: statement above. The 
  985. values for c1,c2 and c3 are the new color numbers for the three colors.  
  986.  
  987. The foreground color command of the TYPE SCREEN statement and the #n command 
  988. of the TYPE statement both provide a means of changing the text color. Both 
  989. of these commands set the new value for color number 3 of the font. So for 
  990. fonts which are defined in one color, the same commands used when not in font 
  991. display mode are used to set the text color in font display mode as well.  
  992.  
  993.  
  994. HOW TO READ A FONT
  995.  
  996. To use a font the program must first set up a string variable long enough to 
  997. contain the font, and must read the font file into the string variable. By 
  998. convention, PILOT font files have a file name suffix of ".PIF". The following 
  999. example shows how to read a font file into a string variable.  
  1000.  
  1001. EXAMPLE 1: read a font file
  1002.  
  1003.        D: F$(5000)
  1004.        FX: HELV9.PIF
  1005.        FI: 0,F$
  1006.  
  1007.  
  1008. FONT CURSOR ADDRESSING
  1009.  
  1010. Characters are displayed in font mode with proportional spacing. This means 
  1011. that each character is only as wide as necessary. Also, a character can be 
  1012. displayed at any pixel boundary, not only at the pre-defined character cells 
  1013. of normal text. When in font display mode the text cursor is kept in terms of 
  1014. pixels, not character cells. The cursor is considered to be at the upper left 
  1015. pixel of the cell in which the next character would be displayed. The XCR and 
  1016. YCR functions return pixel values in this mode.  
  1017.  
  1018. Viewports can be used with font display mode, but the viewport boundaries are 
  1019. still expressed in the character boundaries used for non-font mode. The 
  1020. result is that viewports are always defined on 8 pixel boundaries though the 
  1021. characters in the viewport might be displayed at any pixel. Cursor addressing 
  1022. within a viewport is relative to the home pixel of the viewport (upper left 
  1023. pixel).  
  1024.  
  1025. Proportional spacing improves readability and permits more text per line but 
  1026. it somewhat complicates the issue of cursor row/column addressing.  The GOTO 
  1027. command of the TS: statement may be used to move the cursor to any screen 
  1028. position by specifying a row and column coordinate. Since each character is 
  1029. different size, each font has a default character cell height and width 
  1030. defined. These values usually represent average character size for the font. 
  1031. These average sizes are used to position the font text cursor. The cursor is 
  1032. positioned at the pixel represented by the column and row values multiplied 
  1033. by the default character cell size.  
  1034.  
  1035. The NH: statement provides a means of altering the effect of cursor 
  1036. addressing. With NH: the program can change the values multiplied by the row 
  1037. and column numbers. The most typical case is to execute the statement  NH:1,1  
  1038. after executing the NS: statement.  This sets cursor addressing to pixel 
  1039. coordinates giving the program the ability to address the font text cursor to 
  1040. an absolute pixel.  
  1041.  
  1042.